package com.kkshop.gwt.widget.wizard;

public interface Wizard {
	
	/**
	 * is called right before the widgets are created. can be used to lazily
	 * create pages.
	 * 
	 */
	public void addPages();
	
	/**
	 * Called when the user cancels the wizard.
	 */
	public void cancel();

	/**
	 * Called when the user wants to 'finish'.
	 * 
	 * @return true on success, false on error.
	 */
	public boolean finish();
	
	/**
	 * Should return true if the wizard is done and the user is allowed to click 'Finish'.
	 * @return true if user can finish.
	 */
	public boolean canFinish();
	
	/**
	 * Returns the index of the given page.
	 * @param page
	 * @return
	 */
	public int getIndexOfPage(WizardPage page);
	
	/**
	 * Returns the next wizard page coming after 'page'.
	 * 
	 * @param page the current page. (or null if you expect the first one).
	 * @return
	 */
	public WizardPage getNextWizardPage(WizardPage page);
	
	/**
	 * returns the previous wizard page coming before 'page'.
	 * @param wizardPage
	 * @return
	 */
	public WizardPage getPrevWizardPage(WizardPage page);
	
	/**
	 * Returns all available wizard pages.
	 * @return all available wizard pages.
	 */
	public WizardPage[] getWizardPages();
	
	/**
	 * Returns the wizard widget in which this wizard is displayed
	 * @return the wizard widget in which this wizard is displayed
	 */
	public WizardWidget getWizardWidget();
	
	/**
	 * Sets the wizard widget - this is usally called when the {@link WizardWidget} intializes.
	 * @param wizardWidget the wizard widget in which this wizard is used.
	 */
	public void setWizardWidget(WizardWidget wizardWidget);

}
